export function getDateRang(val, list) {
	console.log(list);
	const now = new Date();
	const nowDayOfWeek = now.getDay();
	const nowDay = now.getDate();
	const nowMonth = now.getMonth();
	const nowYear = now.getFullYear();
	const jd = Math.ceil((nowMonth + 1) / 3);
	let startTime;
	let endTime;
	let customTime = [];
	switch (val) {
		case "today": // 昨日
			startTime = new Date(nowYear, nowMonth, nowDay);
			endTime = new Date(nowYear, nowMonth, nowDay);
			break;
		case "yesterday": // 昨日
			startTime = new Date(nowYear, nowMonth, nowDay - 1);
			endTime = new Date(nowYear, nowMonth, nowDay);
			break;
		case "pastWeek": // 近 7 日
			startTime = new Date(nowYear, nowMonth, nowDay - 7);
			endTime = new Date(nowYear, nowMonth, nowDay);
			break;
		case "pastMonth": // 近 31 日
			startTime = new Date(nowYear, nowMonth, nowDay - 30);
			endTime = new Date(nowYear, nowMonth, nowDay);
			break;
		default: // 自定义时间
			startTime = new Date(list.startDate);
			endTime = new Date(list.endDate);
			break;
	}


	return customTime.length ?
		customTime : [formatDate(startTime), formatDate(endTime)];
}


function formatDate(date) {
	const y = date.getFullYear();
	let m = date.getMonth() + 1;
	m = m < 10 ? `0${m}` : m;
	let d = date.getDate();
	d = d < 10 ? `0${d}` : d;
	return `${y}-${m}-${d}`;
}